package oop2.ch6;

/**
 * @author oldliu
 * @since 1.0
 */
public class PostBachelorClass {
    String name;
    String teacherName;
    String date;
    int count = 0;
    JavaStudent[] s1 = new JavaStudent[30];

    public PostBachelorClass() {
//        for (int i = 0; i <s1.length ; i++) {
//            s1[i]=new JavaStudent();
//        }
    }

    //新人的，假定学号不允许重复！
    public boolean in(JavaStudent ss) {
        if (count >= s1.length) {
            System.out.println("满了");
            return false;
        }
        for (int i = 0; i <count ; i++) {
            if(s1[i].num.equals(ss.num)){
                return false;
            }

        }
        s1[count] = ss;
        count++;
        return true;
    }

    public void in(String name, String num, String zhuanye, String tel) {
        if (count >= s1.length) {
            System.out.println("满了");
            return;
        }
        //s1[count].num=num;
        //s1[count].name=name;
        s1[count] = new JavaStudent(name, num, zhuanye, tel);

        count++;
    }

    public void show() {
        System.out.println("班级名" + name);
        System.out.println("老师" + teacherName);
        System.out.println("地址" + date);
        System.out.println("人数" + count);
        for (int i = 0; i < count; i++) {
            s1[i].show();
        }
    }

}
